import React from 'react';
import { Modal } from 'antd';
// import moment from 'moment';
import SelectTime from '../SelectTime.jsx';

class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      modalVis: true,
      // value: {
      //   timeUnit: '年',
      //   startTime: moment(`${moment().startOf('year').format('YYYY') - 4}`),
      //   endTime: moment().startOf('year'),
      // },
    };
  }
  // 关闭modal框
  onModalCancel = () => {
    this.setState({
      modalVis: false,
    });
  };
  timeChange = obj => {
    // this.setState({
    //   value: obj,
    // });
    const startTime = obj.startTime.format('YYYY-MM-DD');
    const endTime = obj.endTime.format('YYYY-MM-DD');
    console.log(startTime,endTime);
  };
  render() {
    return (
      <Modal
        title="选择日期"
        visible={this.state.modalVis}
        onCancel={this.onModalCancel}
        footer={null}
        width={600}
      >
        <SelectTime
          onChange={this.timeChange}
          /* defaultValue={{
            timeUnit: '年',
            startTime: moment(
              `${moment()
                .startOf('year')
                .format('YYYY') - 9}`
            ),
            endTime: moment().startOf('year'),
          }}
          // size="small"
          value={this.state.value} */
        />
      </Modal>
    );
  }
}

export default Demo;
